
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="page/head.jsp" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-md-10 col-md-offset-1">
            <form class="form-inline" action="/emp/getEmpByPage" method="get">
                <div class="form-group">
                    <label for="exampleInputName2">员工名</label>
                    <input type="text" class="form-control" name="ename" id="exampleInputName2" placeholder="ename">
                </div>
                <div class="form-group">
                    <label>日期:</label>
                    <input type="date" class="form-control" name="start"> 至
                    <input type="date" class="form-control" name="end">
                </div>
                <div class="form-group">
                    <label>性别:</label>
                    <input type="radio" class="form-control" value="男" name="esex"> 男
                    <input type="radio" class="form-control" value="女" name="esex">女
                </div>
                <div class="form-group">
                <button type="submit" class="btn btn-default">查询</button>
                </div>
            </form>
        </div>
    </div>
    <div style="margin-bottom: 10px" class="col-md-1 col-md-offset-1">
        <a href="/addEmp.jsp" class="btn btn-success" role="button">新增员工信息</a>
    </div>
    <div class="row">
        <div class="col-md-10 col-md-offset-1">
            <table class="table table-bordered table-hover">
                <thead>
                <tr>
                    <th>员工编号</th>
                    <th>员工姓名</th>
                    <th>员工性别</th>
                    <th>员工工资</th>
                    <th>员工密码</th>
                    <th>员工部门</th>
                    <th>员工出生日期</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="e" items="${info.list}">
                <tr>
                    <td>${e.eno}</td>
                    <td>${e.ename}</td>
                    <td>${e.esex}</td>
                    <td>${e.salary}</td>
                    <td>${e.pwd}</td>
                    <td>${e.dno}</td>
                    <td>
                        <fm:formatDate value="${e.birthday}" pattern="yyyy-MM-dd"/>
                    </td>
                    <td>
                        <button type="button" class="btn btn-danger" onclick="del(${e.eno})">删除</button>
                        <button type="button" class="btn btn-warning" onclick="updateEmp(${e.eno})">修改</button>
                    </td>
                </tr>
                </c:forEach>
                </tbody>
                <tfoot>
                <tr align="center">
                    <td colspan="8">
                        <nav aria-label="Page navigation">
                            <ul class="pagination">
                                <li>
                                    <a href="/emp/getEmpByPage?pageNum=1" aria-label="Previous">
                                        <span aria-hidden="true">首页</span>
                                    </a>
                                </li>
                                <li>
                                    <a href="/emp/getEmpByPage?pageNum=${info.prePage}" aria-label="Previous">
                                        <span aria-hidden="true">&laquo;</span>
                                    </a>
                                </li>
                                <c:forEach var="i" items="${info.navigatepageNums}">
                                <li ${info.pageNum==i?"class='active'":""}><a href="/emp/getEmpByPage?pageNum=${i}">${i}</a></li>
                                </c:forEach>
                                <li>
                                    <a href="/emp/getEmpByPage?pageNum=${info.nextPage}" aria-label="Next">
                                        <span aria-hidden="true">&raquo;</span>
                                    </a>
                                </li>
                                <li>
                                    <a href="/emp/getEmpByPage?pageNum=${info.pages}" aria-label="Next">
                                        <span aria-hidden="true">尾页</span>
                                    </a>
                                </li>
                            </ul>
                        </nav>
                    </td>
                </tr>
                </tfoot>
            </table>
        </div>
    </div>
</div>
<script>
    function del(eno) {
        if (confirm("是否确认删除")) {
            $.ajax({
                url:"/emp/del?eno="+eno,
                type:"get",
                success:function (result) {
                    if (result==1) {
                       alert("删除成功");
                       location.reload();
                    }else{
                        alert("删除失败");
                    }
                }
            })
        }
    }

    function updateEmp(eno) {
        location.href="/emp/getEmpByEno?eno="+eno;
    }
</script>
</body>
</html>
